package com.ly.mpayment.core.util;

import org.springframework.beans.factory.annotation.Autowired;

import com.ly.mpayment.persist.entity.Mobile;
import com.ly.mpayment.persist.service.mobile.IMobileService;

import net.sf.json.JSONObject;

public class MobileUtil {
	
	@Autowired
	IMobileService weiliuService;
	
//	public String getCity(String phoneNum){
//		String province = "";
//		Mobile weiliu = weiliuService.findPhone(phoneNum.substring(0, 7));
//		if (weiliu == null) {
//			JSONObject weiliuJson = HttpClient.httpGet(phoneNum);
//			// {"mts":"1878243","province":"四川","catName":"中国移动","telString":"","areaVid":"30508","ispVid":"3236139","carrier":"四川移动"}
//			province = weiliuJson.isEmpty() ? ""
//					: weiliuJson.getString("province").equals("") ? null : weiliuJson.getString("province");
//			if (province != null) {
//				// 更新新的电话号段到本地数据库中
//				weiliu = new Mobile();
//				weiliu.setCityCode(weiliuJson.getString("areaVid"));
//				weiliu.setPhone(phoneNum.substring(0, 7));
//				weiliu.setProvince(weiliuJson.getString("province"));
//				weiliu.setServiceProvider(weiliuJson.getString("catName"));
//				weiliuService.saveMobile(weiliu);
//			} else {
//				return ResultMessage.getFailt(ResultMessage.phoneNumError);
//			}
//		}
//		province = weiliu != null ? weiliu.getProvince() : province;
//		return province;
//	}
	public static void main(String[] args) {
//		System.out.println(HttpClient.httpGet("18878784523"));
	}
}
